<?php
if(!empty($_POST))
{
	if(isset($_POST['Delete']))
	{
		$con = Connect();
		mysql_query("DELETE FROM message WHERE TimeStamp='".$_POST['Delete']."'");
		Close($con);
		header("refresh;");
	}
}
?>
<form method="POST">
	<table class="Message">
		<tbody>
			<tr>
				<th>Nachricht erstellen</th>
			</tr>
			<?php
				$con = Connect();
				$set = mysql_num_rows(mysql_query("SELECT * FROM message WHERE ToID LIKE'".$_SESSION['ID']."'"));
				if($set != 0)
				{
					$check = mysql_query("SELECT * FROM message WHERE ToID LIKE '".$_SESSION['ID']."'");
					while($row = mysql_fetch_object($check))
					{
						echo '<tr><th style="text-align:left; width:auto">Absender: '.C_GetName($row->ID).'</th><th style="width:auto">'.$row->Title.'</th>';
						echo '<th style="width:10px;"><a href="index.php?page=MsgEdit&value='.$row->TimeStamp.'"><button type="button" class="buttonX" name="Answer">A</button></a><button type="submit" class="buttonX" name="Delete" value="'.$row->TimeStamp.'">X</button></th></tr>';
						echo '<tr><th style="width:500px; height:auto">'.$row->Text.'</th></tr>';
					}
				}		
				Close($con);
			?>
		</tbody>
	</table>
</form>